// 用于登陆的时候的状态

import { Login_fail, Login_loading, Login_start, Login_success } from "../Type";

let login_info = {
    state: 'default',
    login: false,
    loading: false,
    data: {
        user_id: '',
        user_phone: '',
        user_name: '',
        user_pic: 'https://profile.csdnimg.cn/D/6/0/2_baicie',
        user_password: '',
        user_email: ''
    }
}

const login = (status = login_info, action) => {
    if (action.type === Login_loading) {
        return {
            state: action.msg,
            login: false,
            loading: true,
            data:login_info.data
        }
    }
    if (action.type === Login_success) {
        return {
            state: action.msg,
            login: true,
            loading: true,
            data: action.data
        }
    }
    if (action.type === Login_fail) {
        return {
            state: action.msg,
            login: false,
            loading: false,
            data:login_info.data
        }
    }
    return status
}

export default login;